package com.kancy.qrshare.common;

import java.util.Properties;

/**
 * 常量
 * @author kancy
 *
 */
public class Constants {
	public static final String CHARACTER_UTF8 = "UTF-8";
	public static final String CHARACTER_GBK = "GBK";
	public static final String CHARACTER_ISO8859_1 = "ISO8859-1";
	//---------------------------------------------------------
	// http://tool.oschina.net/commons
	//---------------------------------------------------------
	public static final String CONTENT_TYPE_IMAGE = "image/jpeg";
	public static final String CONTENT_TYPE_GIF = "image/gif";
	public static final String CONTENT_TYPE_PNG = "image/png";
	public static final String CONTENT_TYPE_ICO= "image/x-icon";
	public static final String CONTENT_TYPE_JPG = "image/jpeg";
	public static final String CONTENT_TYPE_JPEG = "image/jpeg";
	public static final String CONTENT_TYPE_BMP = "image/jpeg";
	public static final String CONTENT_TYPE_HTML = "text/html";
	public static final String CONTENT_TYPE_DEFAULT = "application/octet-stream";

	private static Properties staticResourceContentTypes = new Properties();
	static{
		staticResourceContentTypes.setProperty(".html", CONTENT_TYPE_HTML);
		staticResourceContentTypes.setProperty(".htm", CONTENT_TYPE_HTML);
		staticResourceContentTypes.setProperty(".gif", CONTENT_TYPE_GIF);
		staticResourceContentTypes.setProperty(".png", CONTENT_TYPE_PNG);
		staticResourceContentTypes.setProperty(".ico", CONTENT_TYPE_ICO);
		staticResourceContentTypes.setProperty(".jpeg", CONTENT_TYPE_JPG);
		staticResourceContentTypes.setProperty(".jpg", CONTENT_TYPE_JPEG);
		staticResourceContentTypes.setProperty(".bmp", CONTENT_TYPE_BMP);
	}

	public static String getContentType(String fileSuffix){
		assert fileSuffix != null;
		return staticResourceContentTypes.getProperty(fileSuffix.trim().toLowerCase(), CONTENT_TYPE_DEFAULT);
	}

}
